package com.gdk.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.gdk.service.ArticleService;
import com.gdk.service.BannerService;
import com.gdk.service.GoodsService;
import com.gdk.service.LoginService;
import com.gdk.service.NavigationService;
import com.gdk.service.QyService;
import com.gdk.service.SetService;
import com.gdk.service.TreeService;
import com.gdk.utils.XVDateUtils;


/**
 * 权益controller
 * */

@Controller
public class QyController {
	
	@Autowired
    private QyService qyService;
	/**
	 * 查询所有权益
	 * */
	@RequestMapping("/selectAllQy.do")
	public String selectAllQy(HttpServletRequest request) {
		List<Map<String, Object>> allQy = qyService.selectAllQy();
		request.setAttribute("allQy", allQy);
		return "jsp/qy/qy-list";
	}
	
	
	/**
	 *修改前查询权益详情
	 * */
	@RequestMapping("/preSelectQyDetails.do")
	public String preSelectQyDetails(@RequestParam Map<String,Object> map, HttpServletRequest request) {
		
		Map<String, Object> qyDetails = qyService.selectQyDetails(map);
		
		
			/*if(treeDetails.get("ft_endtime") != null) {
				int p = Integer.valueOf(treeDetails.get("ft_endtime").toString());
				if(p != 0) {
					treeDetails.put("ft_endtime", XVDateUtils.MillisFormat(p));	
				}
			}
			*/
		
		request.setAttribute("qyDetails",qyDetails);
		return "jsp/qy/qy-edit";
	}
	
	/**
	 * 修改权益
	 * */
	@ResponseBody
	@RequestMapping("/updateQy.do")
	public int updateQy(@RequestParam Map<String,Object> map, HttpServletRequest request) {
		int set = qyService.updateQyDetails(map);
		return set;
	}


}